﻿using Online_Course.Core;
using Online_Course.Domain;
using Online_Course.Service;
using Online_Course.Web.Apps;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace Online_Course.Web.Controllers
{
    public class HomeController : Controller
    {
            public ActionResult Index()
            {
                return View();
            }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult MenuIndex()
        {
            ViewBag.PrivilegeList = AppHelper.Privileges;
            return View();
        }

        [HttpPost]
        public string menuindex(int id)
        {
            string password = "E10ADC3949BA59ABBE56E057F20F88";
            string Massage = "";
            int Userid = AppHelper.LoginedUser.ID;
            IList<SysRole> Role = AppHelper.LoginedUser.SysRoleList;
            SysUser User = Container.Instance.Resolve<ISysUserService>().GetEntity(Userid);
            for (int Count = 0; Count < Role.Count;Count++)
            {
               if (password == User.Password && Role[Count].Name=="教师")
                {
                    Massage="您的密码为初始密码，建议您尽快修改密码！";
                    break;
                }
            }
            if (Massage == "")
                return null;
            else
                return Massage;
        }

        public ActionResult Top()
        {
            ViewBag.LoginUser = AppHelper.LoginedUser.Name;
            return View();
        }
        public ActionResult MessagesList()
        {
            return View();
        }
    }
}